Skip to content

[codex] fix research agent tool loop - #96

Draft
doublew6 wants to merge 1 commit into
FinStep-AI:mainfrom
doublew6:codex/fix-research-agent-loop
Draft

[codex] fix research agent tool loop#96
doublew6 wants to merge 1 commit into
FinStep-AI:mainfrom
doublew6:codex/fix-research-agent-loop

Conversation

@doublew6

@doublew6 doublew6 commented May 9, 2026

Copy link
Copy Markdown

What changed

  • Allow LangChain StructuredTool instances to register in ToolManager by accepting tools that expose invoke.
  • Stop the research-agent ReAct loop once max_react_step is reached, even after tool-selection errors.
  • Record tool-selection errors as tool steps so repeated invalid selections can make progress toward the configured limit.
  • Add unittest coverage for tool registration and loop termination behavior.

Why

The CLI could appear stuck during the research phase: one research agent completed, while another kept cycling through tool_selection -> call_tool and never wrote a report. The root causes were an empty/under-registered toolset for LangChain tools plus termination logic that let tool-selection errors bypass the max-step cutoff.

Validation

  • .venv/bin/python -m unittest tests/test_research_agent_loop.py
  • .venv/bin/python -m py_compile contest_trade/agents/research_agent.py contest_trade/tools/tool_utils.py tests/test_research_agent_loop.py
  • .venv/bin/python -m cli.main config
  • git diff --cached --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant